const koa = require('koa');
const router = require('koa-router');
const betterBody = require('koa-better-body');
const conver = require('koa-convert');
const pathlib = require('path');

let server = new koa();
server.listen(8080);

let r1 = router();
server.use(r1.routes());
r1.use(conver(betterBody({
    uploadDir: pathlib.resolve('./upload'),
    keepExtensions: true,
})));

r1.post('/api', async (ctx, next) => {
    console.log(ctx.request.fields);
    console.log(ctx.request.files);
})